package es.uji.viselab.task;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import es.uji.viselab.experiment.DataArrivalListener;
import es.uji.viselab.network.DataPackage;


public abstract class NetworkTaskLink {
	
	

	
	List<DataArrivalListener> eventListeners = new ArrayList<DataArrivalListener>();

	public void addDataArrivalListener(DataArrivalListener dal) {
		eventListeners.add(dal);
	}

	protected void notifyDataArrival(DataPackage dn) {
		Iterator<DataArrivalListener> iterator = eventListeners.iterator();
		while (iterator.hasNext()) {
			DataArrivalListener da = iterator.next();
			da.newDataArrived(dn);
		}
	}
	

	public void notifyConnectionStablished() {
		Iterator<DataArrivalListener> iterator = eventListeners.iterator();
		while (iterator.hasNext()) {
			DataArrivalListener da = iterator.next();
			da.newConnectionStablished();		}
	}

	public abstract void send(DataPackage dn);

	public abstract void keepReceiving();
	public void start() {
		// TODO Auto-generated method stub
	}
	
	

}
